import requests,unittest,json
import parameterized
from api.yun_login import test_01
from app import BASE_URL


def build_data():
    #准备json路径
    str_path = BASE_URL+"/data/yun.json"
    print(str_path)

    #打开文件获取数据
    with open(str_path,"r") as f:
        res = f.read()
        dict_res = json.loads(res)

        list = []
        #组装数据
    for i in dict_res["data"]:
        tupe = (i["username"],i["password"],i["code"])
        list.append(tupe)
    return list


class TestSum(unittest.TestCase):
    @parameterized.parameterized.expand(build_data())
    def test_02(self,username,password,code):
        user = test_01(username,password)

        self.assertEqual(user["result"],code)


